home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Behavior Library.cst / 00010_Open Movie in a Window.ls < prev    next >
Encoding:
Text File  |  1997-05-09  |  5.8 KB  |  173 lines

  1. -- Movie in a Window    Open
  2.  
  3.  
  4. -- Opens a Movie In a Window, a director file that runs alongside the current movie.
  5. -- Use with the "Message Movie In a Window" Behavior to control the MIAW
  6.  
  7. -- also functions through lingo by handling message 'initOpenMIAW', 
  8. -- for example if this behavior was assigned to sprite 5, use
  9. -- sendsprite 5, #initOpenMIAW
  10.  
  11. property  windowLeft, windowTop, windowWidth, windowHeight
  12. property  windowMovie, windowName, windowType
  13. property  scrollable, sizable, zoomable, invisible
  14. property  whichEvent
  15.  
  16. on initOpenMIAW me
  17.   init me
  18. end
  19.  
  20. on mouseUp me
  21.   if whichEvent = #mouseup    then init me
  22. end
  23.  
  24. on prepareFrame me
  25.   if whichEvent = #prepareframe then init me
  26. end
  27.  
  28. on exitFrame me
  29.   if whichEvent = #exitframe  then init me
  30. end
  31.  
  32. on init me
  33.   set w = get_previous_instance( the WindowList, the windowName of me )
  34.   -- dispose of window if already open
  35.   if objectP( w ) then
  36.     forget w 
  37.   end if
  38.   -- initialize from behavior parameters
  39.   if the windowName of me <> EMPTY then
  40.     set w = window the windowName of me
  41.     set the titleVisible of w = TRUE
  42.   else
  43.     set w = window "temp"
  44.     set the titleVisible of w = FALSE
  45.   end if
  46.   set the fileName of w = get_filename( the windowMovie of me )
  47.   set the windowType of w = get_window_style( me )
  48.   set the rect of w = rect( the windowLeft of me, the windowTop of me, ┬¼
  49.                                    ( the windowLeft of me + the windowWidth  of me ), ┬¼
  50.                                    ( the windowTop  of me + the windowHeight of me ))
  51.   open w
  52.   
  53. end
  54.  
  55. ---
  56.  
  57. on get_previous_instance w_list, w_name
  58.   repeat with i = count( w_list ) down to 1
  59.     set w = getAt( w_list, i )
  60.     if the name of w = w_name then 
  61.       return( w )
  62.     end if
  63.   end repeat
  64.   return( -1 )
  65. end
  66.  
  67. on get_window_style me
  68.   case ( the windowType of me ) of:
  69.     #Document:
  70.       if the zoomable of me then
  71.         if the sizable of me then 
  72.           set t = 8
  73.         else
  74.           set t = 12
  75.         end if
  76.       else  -- NOT zoomable
  77.         if the sizable of me then 
  78.           set t = 0
  79.         else
  80.           set t = 4
  81.         end if
  82.       end if
  83.       
  84.     #Palette: 
  85.       set t = 49
  86.     #Rounded: 
  87.       set t = 16
  88.     #Plain:   
  89.       set t = 2
  90.     #Shadow:  
  91.       set t = 3
  92.     #"Modal Dialog":  
  93.       set t = 1
  94.     #"Movable Modal Dialog":  
  95.       set t = 5
  96.     otherwise: set t = 4
  97.   end case
  98.   return( t )
  99. end
  100.  
  101. on get_filename f_name
  102.   -- don't force user to remember the extension
  103.   if NOT ( f_name contains ".dir" ) then
  104.     set f_name = f_name & ".dir"
  105.   end if
  106.   -- support relative pathnames
  107.   if (( f_name contains "/" ) OR ┬¼
  108.       ( f_name contains "\" )) then
  109.     if ( NOT f_name contains ":" ) then
  110.       set f_name = the pathname & f_name
  111.     end if
  112.   end if
  113.   return( f_name )
  114. end
  115.  
  116. on getPropertyDescriptionList
  117.   
  118.   set p_list = [ ┬¼
  119.    #windowMovie: [ #comment:   "Movie Name:", ┬¼
  120.                     #format:   #string, ┬¼
  121.                    #default:    "" ], ┬¼
  122.     #windowName: [ #comment:   "Window Name:", ┬¼
  123.                     #format:   #string, ┬¼
  124.                    #default:    "" ],┬¼
  125.     #windowType: [ #comment:   "Window Style:", ┬¼
  126.                     #format:   #symbol, ┬¼
  127.                      #range: [ #Document, #Palette, #Rounded, #Plain, #Shadow, ┬¼
  128.                               #"Modal Dialog", #"Movable Modal Dialog" ], ┬¼
  129.                    #default:    #Document ], ┬¼
  130.        #sizable: [ #comment:   "Resize Box:", ┬¼
  131.                     #format:   #boolean, ┬¼
  132.                    #default:    FALSE ], ┬¼
  133.     #windowLeft: [ #comment:   "Left:", ┬¼
  134.                     #format:   #integer, ┬¼
  135.                    #default:    100 ], ┬¼
  136.      #windowTop: [ #comment:   "Top:", ┬¼
  137.                     #format:   #integer, ┬¼
  138.                    #default:    100 ], ┬¼
  139.    #windowWidth: [ #comment:   "Width:", ┬¼
  140.                     #format:   #integer, ┬¼
  141.                    #default:    0 ], ┬¼
  142.   #windowHeight: [ #comment:   "Height:", ┬¼
  143.                     #format:   #integer, ┬¼
  144.                    #default:    0 ], ┬¼
  145.       #zoomable: [ #comment:   "Zoom Box:", ┬¼
  146.                       #format:   #boolean, ┬¼
  147.                      #default:    FALSE ], ┬¼
  148.   #WhichEvent: [ #comment:   "Initializing Event:", ┬¼
  149.                     #format:   #symbol, ┬¼
  150.                      #range: [ #MouseUp, #PrepareFrame, #ExitFrame, #InitOpenMIAW], ┬¼
  151.                    #default:   #MouseUp ] ┬¼
  152.                  ]
  153.   return p_list 
  154.   
  155.   
  156.   
  157. end
  158.  
  159. on getBehaviorDescription
  160.   ┬¼
  161.  return ┬¼
  162. "Opens a Director movie in a window of the designated type. This behavior can be triggered by a specified event or by receiving the initOpenMIAW message. If width and height parameters are set to 0 (the default), the movie opens at it's original size." & RETURN & ┬¼
  163. "PARAMETERS:" & RETURN & ┬¼
  164. "ΓÇó Movie Name - Enter the file name of the movie to be opened." & RETURN & ┬¼
  165. "ΓÇó Window Name - ( optional ) Enter the label to be displayed in window header, when visible." & RETURN & ┬¼
  166. "ΓÇó Window Style - Choose a border style and interactivity options. The choices are: Document (moveable, sizeable window without a zoom box), Palette (floating palette), Rounded (rounded corners), Plain (plain box, no title bar), Shadowed (plain box with shadow, no title bar), Modal Dialog, and Moveable Modal Dialog " & RETURN & ┬¼
  167. "ΓÇó Resize Box - Turn this option on to make the window resizable when appropriate." & RETURN & ┬¼
  168. "ΓÇó Left, Top - Enter the initial offset ( in pixels ) of the window from the upper left corner of the display." & RETURN & ┬¼
  169. "ΓÇó Width, Height - ( optional ) Enter the initial dimensions ( in pixels ) of the window."  & RETURN & ┬¼
  170. "ΓÇó Zoom Box - Turn this option on to add a minimize/maximize button to the title bar when appropriate." & RETURN & ┬¼
  171. "ΓÇó Initializing Event - Choose the event that triggers the behavior. Choose initOpenMIAW to make the behavior run when it receives this message."
  172. end
  173.